<?php
require 'getFriendsForUser.php';
require 'getLinksForUser.php';

/*
args: user
      link

functionality: checks if there is a friend related to the particular link
returns true or false accordingly
*/

function FriendRelatedToFriendsExists($user, $link){
	$appFriends = getFriendsForUser($user);
	$i = 0;
	//for every friend
	foreach ($appFriends as $friend){
		$friendLinks = getLinksForUser($friend);
		
		//for every link the friend is "into this"
		foreach ($friendLinks as $friendLink){
			$score = blackBox($link, $friendLink);
			if ( $score>0.8)
				return true;
		}
		
	}
	return false;
	
}

function blackBox($url1, $url2){

	return rand( 0 , 1000 )/1000;;
}


?>